<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>云借阅-图书管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/pages-login-manage.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
</head>
<body>
<div class="loginmanage">
    <div class="py-container">
        <h4 class="manage-title">云借阅-图书管理系统</h4>
        <div class="loginform">
            <ul class="sui-nav nav-tabs tab-wraped">
                <li class="active">
                    <h3>账户登录</h3>
                </li>
            </ul>
            <div class="tab-content tab-wraped">
                <%--登录提示信息--%>
                <span style="color: red">${msg}</span>
                <div id="profile" class="tab-pane  active">
                    <form id="registerform" class="sui-form" name="registerform" onsubmit="return submit1()" action="${pageContext.request.contextPath}/register"
                          method="post">
                        <div class="input-prepend"><span class="add-on loginname">昵称</span>
                            <input type="text" placeholder="称呼" class="span2 input-xfat" name="name">
                        </div>
                        <div class="input-prepend"><span class="add-on loginname">用户名</span>
                            <input type="text" placeholder="企业邮箱" class="span2 input-xfat" name="email" onblur="checkemail()">
                        </div>
                        <div class="input-prepend"><span class="add-on loginpwd">密码</span>
                            <input type="password" placeholder="请输入密码" class="span2 input-xfat" name="password">
                        </div>
                        <div class="input-prepend"><span class="add-on loginpwd">确认密码</span>
                            <input type="password" placeholder="请输入密码" class="span2 input-xfat" name="password1" onblur="checkpass()" >
                        </div>

                        <div class="register">
                            <button type="submit" class="sui-btn btn-block btn-xlarge btn-danger" id="submit">注&nbsp;&nbsp;册</button>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    /**
     * 登录超时 展示区跳出iframe
     */
    var _topWin = window;
    while (_topWin != _topWin.parent.window) {
        _topWin = _topWin.parent.window;
    }
    if (window != _topWin)
        _topWin.document.location.href = '${pageContext.request.contextPath}/admin/login.jsp';
    function checkemail(){

        var email = document.registerform.email.value; // 获取表单提交的邮箱地址
        if(email===""||email==null){
            alert("用户名不可为空")
            return false;
        }
        var emailPattern = "[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+"; // 定义邮箱[正则表达式]
        if (!email.matches(emailPattern)) {
          alert('邮箱格式错误');
          return false;
        }
        return true;
    }
    function checkpass(){
        var pas1 = document.registerform.password.value
        var pas2 = document.registerform.password1.value
        if(pas1==""||pas1==null||pas2==""||pas2==null){
            alert("密码不可为空")
            return false;
        }
        if(pas1!==pas2){
            alert("两次密码不一致,请检查后重新输入");
            return false;
        }
        return true;
    }

    function submit1(){
        return (checkpass()&&checkemail());
    }

</script>
</html>